<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>深拷贝方法二和方法三</title>
  </head>
  <body>
    <!-- 
        使用js的库lodash 里面cloneDeep内部实现了深拷贝
        直接使用就行
     -->
    <script src="http://cdn.staticfile.org/lodash.js/4.17.21/lodash.min.js"></script>
    <script>
      const obj = {
        uname: "luochun",
        age: 18,
        hobby: ["羽毛球", "足球", "乒乓球"],
        family: {
          baby: "luochen",
        },
        a: function() {}
      };

      const o = _.cloneDeep(obj);

      o.family.baby = 'luoxinyu'
      console.log(o);
      console.log(obj);

      console.log('🚀 ~ This is a result of console.log ~ ✨: ', o.a === obj.a);

      //  ===========================方法三==============================
      const b = JSON.parse(JSON.stringify(obj))
      
    </script>
  </body>
</html>
